import request from '@/utils/request'

/**
 * 志愿者管理API接口
 */

// 志愿者申请管理相关接口

// 提交志愿者申请
export function submitVolunteerApplication(applicationData) {
  return request({
    url: '/api/volunteers/applications',
    method: 'post',
    data: applicationData
  })
}

// 分页查询志愿者申请列表
export function getVolunteerApplications(currentPage, pageSize, queryData) {
  return request({
    url: `/api/volunteers/applications/page/${currentPage}/${pageSize}`,
    method: 'get',
    params: queryData
  })
}

// 根据ID查询申请详情
export function getApplicationById(applicationId) {
  return request({
    url: `/api/volunteers/applications/${applicationId}`,
    method: 'get'
  })
}

// 审核志愿者申请
export function reviewVolunteerApplication(applicationId, reviewData) {
  return request({
    url: `/api/volunteers/applications/${applicationId}/review`,
    method: 'put',
    data: reviewData
  })
}

// 撤销志愿者申请
export function withdrawApplication(applicationId) {
  return request({
    url: `/api/volunteers/applications/${applicationId}/withdraw`,
    method: 'put'
  })
}

// 志愿者任务分配相关接口

// 分配志愿者任务
export function assignVolunteerTask(taskData) {
  return request({
    url: '/api/volunteers/tasks',
    method: 'post',
    data: taskData
  })
}

// 分页查询志愿者任务列表
export function getVolunteerTasks(currentPage, pageSize, queryData) {
  return request({
    url: `/api/volunteers/tasks/page/${currentPage}/${pageSize}`,
    method: 'get',
    params: queryData
  })
}

// 根据ID查询任务详情
export function getTaskById(taskId) {
  return request({
    url: `/api/volunteers/tasks/${taskId}`,
    method: 'get'
  })
}

// 更新任务信息
export function updateVolunteerTask(taskData) {
  return request({
    url: '/api/volunteers/tasks',
    method: 'put',
    data: taskData
  })
}

// 删除任务
export function deleteTask(taskId) {
  return request({
    url: `/api/volunteers/tasks/${taskId}`,
    method: 'delete'
  })
}

// 批量分配任务
export function batchAssignTasks(assignData) {
  return request({
    url: '/api/volunteers/tasks/batch-assign',
    method: 'post',
    data: assignData
  })
}

// 完成任务
export function completeTask(taskId, completionData) {
  return request({
    url: `/api/volunteers/tasks/${taskId}/complete`,
    method: 'put',
    data: completionData
  })
}

// 获取志愿者当前任务
export function getCurrentVolunteerTasks(volunteerId) {
  return request({
    url: `/api/volunteers/tasks/current/${volunteerId}`,
    method: 'get'
  })
}

// 志愿者服务记录查询相关接口

// 获取志愿者服务记录
export function getVolunteerServiceRecords(volunteerId, queryData) {
  return request({
    url: `/api/volunteers/records/${volunteerId}`,
    method: 'get',
    params: queryData
  })
}

// 分页查询所有志愿者服务记录
export function getAllServiceRecords(currentPage, pageSize, queryData) {
  return request({
    url: `/api/volunteers/records/page/${currentPage}/${pageSize}`,
    method: 'get',
    params: queryData
  })
}

// 添加服务记录
export function addServiceRecord(recordData) {
  return request({
    url: '/api/volunteers/records',
    method: 'post',
    data: recordData
  })
}

// 更新服务记录
export function updateServiceRecord(recordData) {
  return request({
    url: '/api/volunteers/records',
    method: 'put',
    data: recordData
  })
}

// 删除服务记录
export function deleteServiceRecord(recordId) {
  return request({
    url: `/api/volunteers/records/${recordId}`,
    method: 'delete'
  })
}

// 导出志愿者服务记录
export function exportServiceRecords(queryData) {
  return request({
    url: '/api/volunteers/records/export',
    method: 'get',
    params: queryData,
    responseType: 'blob'
  })
}

// 志愿者统计分析相关接口

// 获取志愿者统计信息
export function getVolunteerStatistics(queryData) {
  return request({
    url: '/api/volunteers/statistics',
    method: 'get',
    params: queryData
  })
}

// 获取志愿者总数统计
export function getVolunteerCountStatistics() {
  return request({
    url: '/api/volunteers/statistics/count',
    method: 'get'
  })
}

// 获取志愿者服务时长统计
export function getServiceHourStatistics(queryData) {
  return request({
    url: '/api/volunteers/statistics/service-hours',
    method: 'get',
    params: queryData
  })
}

// 获取志愿者任务完成情况统计
export function getTaskCompletionStatistics(queryData) {
  return request({
    url: '/api/volunteers/statistics/task-completion',
    method: 'get',
    params: queryData
  })
}

// 获取志愿者排名统计
export function getVolunteerRankingStatistics(queryData) {
  return request({
    url: '/api/volunteers/statistics/ranking',
    method: 'get',
    params: queryData
  })
}

// 获取部门志愿者统计
export function getDepartmentVolunteerStatistics(departmentId) {
  return request({
    url: `/api/volunteers/statistics/department/${departmentId}`,
    method: 'get'
  })
}

// 志愿者评价管理相关接口

// 提交志愿者任务评价
export function submitVolunteerEvaluation(taskId, evaluationData) {
  return request({
    url: `/api/volunteers/evaluations/${taskId}`,
    method: 'post',
    data: evaluationData
  })
}

// 获取志愿者评价列表
export function getVolunteerEvaluations(volunteerId, queryData) {
  return request({
    url: `/api/volunteers/evaluations/${volunteerId}`,
    method: 'get',
    params: queryData
  })
}

// 分页查询所有评价记录
export function getAllEvaluations(currentPage, pageSize, queryData) {
  return request({
    url: `/api/volunteers/evaluations/page/${currentPage}/${pageSize}`,
    method: 'get',
    params: queryData
  })
}

// 获取任务评价详情
export function getTaskEvaluation(taskId) {
  return request({
    url: `/api/volunteers/evaluations/task/${taskId}`,
    method: 'get'
  })
}

// 更新评价信息
export function updateEvaluation(evaluationData) {
  return request({
    url: '/api/volunteers/evaluations',
    method: 'put',
    data: evaluationData
  })
}

// 删除评价记录
export function deleteEvaluation(evaluationId) {
  return request({
    url: `/api/volunteers/evaluations/${evaluationId}`,
    method: 'delete'
  })
}

// 获取志愿者平均评分
export function getVolunteerAverageScore(volunteerId) {
  return request({
    url: `/api/volunteers/evaluations/average-score/${volunteerId}`,
    method: 'get'
  })
}

// 志愿者工作负载管理相关接口

// 获取可用志愿者列表
export function getAvailableVolunteers(queryData) {
  return request({
    url: '/api/volunteers/workload/available-volunteers',
    method: 'get',
    params: queryData
  })
}

// 获取志愿者工作负载信息
export function getVolunteerWorkload(volunteerId, queryData) {
  return request({
    url: `/api/volunteers/workload/${volunteerId}`,
    method: 'get',
    params: queryData
  })
}

// 分页查询志愿者工作负载列表
export function getVolunteerWorkloads(currentPage, pageSize, queryData) {
  return request({
    url: `/api/volunteers/workload/page/${currentPage}/${pageSize}`,
    method: 'get',
    params: queryData
  })
}

// 更新志愿者工作负载
export function updateVolunteerWorkload(workloadData) {
  return request({
    url: '/api/volunteers/workload',
    method: 'put',
    data: workloadData
  })
}

// 获取超负荷志愿者列表
export function getOverloadedVolunteers(queryData) {
  return request({
    url: '/api/volunteers/workload/overloaded',
    method: 'get',
    params: queryData
  })
}

// 获取志愿者空闲时间
export function getVolunteerAvailableTime(volunteerId, queryData) {
  return request({
    url: `/api/volunteers/workload/available-time/${volunteerId}`,
    method: 'get',
    params: queryData
  })
}

// 批量调整志愿者工作负载
export function batchAdjustWorkload(adjustmentData) {
  return request({
    url: '/api/volunteers/workload/batch-adjust',
    method: 'post',
    data: adjustmentData
  })
}

// 其他辅助接口

// 根据条件搜索志愿者
export function searchVolunteers(searchData) {
  return request({
    url: '/api/volunteers/search',
    method: 'post',
    data: searchData
  })
}

// 获取志愿者个人信息
export function getVolunteerProfile(volunteerId) {
  return request({
    url: `/api/volunteers/profile/${volunteerId}`,
    method: 'get'
  })
}

// 更新志愿者个人信息
export function updateVolunteerProfile(profileData) {
  return request({
    url: '/api/volunteers/profile',
    method: 'put',
    data: profileData
  })
}

// 获取志愿者技能标签
export function getVolunteerSkills(volunteerId) {
  return request({
    url: `/api/volunteers/skills/${volunteerId}`,
    method: 'get'
  })
}

// 添加志愿者技能标签
export function addVolunteerSkill(volunteerId, skillData) {
  return request({
    url: `/api/volunteers/skills/${volunteerId}`,
    method: 'post',
    data: skillData
  })
}

// 删除志愿者技能标签
export function removeVolunteerSkill(volunteerId, skillId) {
  return request({
    url: `/api/volunteers/skills/${volunteerId}/${skillId}`,
    method: 'delete'
  })
}